<?php echo View::factory('admin/travel/travel_left')->render(); ?>
<script charset="utf-8" src="/media/js/editor/kindeditor.js"></script>
<script type="text/javascript" src="/media/js/my_validation.js"></script>
<link href="/media/js/uploadify/uploadify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="/media/js/uploadify/swfobject.js"></script>
<script type="text/javascript" src="/media/js/uploadify/jquery.uploadify.v2.1.4.min.js"></script>
<script>
    
    /****************编辑器 加载开始******************/
    var content;
    KindEditor.ready(function(K) {
        content = K.create('#content');
    });
    var trafficinfo;
    KindEditor.ready(function(K) {
        trafficinfo = K.create('#trafficinfo');
    });
    var bookinfo;
    KindEditor.ready(function(K) {
        bookinfo = K.create('#bookinfo');
    });
    
    /****************编辑器 加载结束******************/    
    $(document).ready(function() {
        $('input.area_tree:checked').each(function() {
            var $area_id = $(this).val();
            var $area_text = $(this).next().text();
            $('.checked_citys_box').append('<div class="checked_citys_'+$area_id+'"><label>'+$area_text+'</label></div>');
        });
        
        
        $('input.area_tree').click(function(){
            var $area_id = $(this).val();
            var $area_text = $(this).next().text();
            if($(this).is(':checked')) {
                $('.checked_citys_box').append('<div class="checked_citys_'+$area_id+'"><label>'+$area_text+'</label></div>');
            } else {
                $('.checked_citys_'+$area_id).remove();
            }
        });
      
    
        
        $('.delete').click(function() {
            var current_id = $(this).text();
            $.ajax({
                type:"POST",
                url:"/admin/uploadify/removeimage",
                data:'id='+$(this).text()+'&table=cheers_travel_sightsimage',
                dataType:'text',
                success:function(data) {
                    if(data == 'true') {
                        $('#removeimage'+current_id).remove();
                    }
                }
            });
        });
     
     
        $( "input:submit").button();
        $('#custom_file_upload').uploadify({
            'uploader'       : '/media/js/uploadify/uploadify.swf',
            'script'         : '/admin/uploadify/images/cheers_travel_sightsimage',
            'cancelImg'      : '/media/js/uploadify/cancel.png',
            'folder'         : '/uploads/sight',
            'multi'          : true,
            'auto'           : true,
            'fileExt'        : '*.jpg;*.gif;*.png',
            'fileDesc'       : 'Image Files (.JPG, .GIF, .PNG)',
            'queueID'        : 'custom-queue',
            'queueSizeLimit' : 300,
            'simUploadLimit' : 2,
            'removeCompleted': false,
            'displayData'   : 'shown',
            'scriptData': {"PHPSESSID":"<?php echo session_id(); ?>",'id':"<?php echo $data->id_sight ?>"},
            'onSelectOnce'   : function(event,data) {
                $('#status-message').text(data.filesSelected + ' files have been added to the queue.');
            },
            'onAllComplete'  : function(event,data) {
                $('#status-message').text(data.filesUploaded + ' files uploaded, ' + data.errors + ' errors.');
            }
        });	
    });
    
</script>
<div id="do_right" class="catalog_right">
    <div class="box" style="overflow:hidden;">
        <h3 id="h3_left">添加景点</h3>
        <div id="right_button"><a href="/admin/sight/list"><button id="back">返回景点列表</button></a></div>
        <div class="clear"></div>

        <form method="post" action="/admin/sight/edit/<?php echo $data->id_sight; ?>" class="need_validation" id="commentForm">
            <div id="tabs">
                <ul>
                    <li><a href="#tabs-1">基本内容</a></li>
                    <li><a href="#tabs-2">景区介绍</a></li>
                    <li><a href="#tabs-3">景区图片</a></li>
                </ul>
                <!--START tabs-1 -->
                <div id="tabs-1">
                    <ul>

                        <li>
                            <label for="name" class="lable_title">景点名称<span class="req">*</span></label>
                            <input name="name" id="name" class="text medium required"  value="<?php echo $data->name; ?>"/>
                        </li>
                        <li > <label for="name" class="lable_title" style="margin-right: 30px;">地区</label>

                            <div style="border: 1px solid #D2D2D2;
                                 margin: 10px 0;
                                 float: left;
                                 padding: 10px;width: 200px;">
                                 <?php echo $catalog_checkboxes_tree; ?>
                            </div>
                            <div used="1" aid="2" id="attr_2_options" class="filter_condition_little_box" style="height:340px;">
                                <div title="您选择的城市" class="filter_condition_little_box_title">您选择的城市</div> 
                                <div class="checked_citys_box">                        

                                  
                                     </div>
                                </div>
                                    </li>
                                    <li>
                                        <label for="name_index" class="lable_title">首字母<span class="req">*</span></label>
                                        <input name="name_index" id="name_index" class="text required "  value="<?php echo $data->name_index; ?>"/>
                                    </li>
                                    <li>
                                        <label for="order" class="lable_title">排序</label>
                                        <input name="order" id="order" class="text number"  value="<?php echo $data->order; ?>"/>
                                    </li>
                                    <li>
                                        <label for="address" class="lable_title">地址<span class="req">*</span></label>
                                        <input name="address" id="address" class="text medium required"  value="<?php echo $data->address; ?>"/>
                                    </li>
                                    <li>
                                        <label for="price" class="lable_title">门票</label>
                                        <input name="price" id="price" class="text"  value="<?php echo $data->price; ?>"/>
                                        <label for="views" class="lable_title">浏览人数</label>
                                        <input name="views" id="views" class="text number"  value="<?php echo $data->views; ?>"/>

                                    </li>

                                    <li>
                                        <label for="opentime" class="lable_title">营业时间</label>
                                        <input name="opentime" id="opentime" class="text medium"  value="<?php echo $data->opentime; ?>"/>
                                    </li>

                                    <li>
                                        <label for="weatherurl" class="lable_title">天气链接</label>
                                        <input name="weatherurl" id="weatherurl" class="text medium url"  value="<?php echo $data->weatherurl; ?>"/>
                                    </li>
                                    <li>
                                        <label for="mapcode" class="lable_title">地图编号</label>
                                        <input name="mapcod" id="mapcode" class="text medium"  value="<?php echo $data->mapcode; ?>"/>
                                    </li>
                                    <li>
                                        <label for="been" class="lable_title">去过人数</label>
                                        <input name="been" id="been" class="text number"  value="<?php echo $data->been; ?>"/>

                                        <label for="want" class="lable_title">想去人数</label>
                                        <input name="want" id="want" class="text number"  value="<?php echo $data->want; ?>"/>
                                    </li>

                                    <li>
                                        <label for="meta_title" class="lable_title">metatitle</label>
                                        <input name="meta_title" id="meta_title" class="text medium"  value="<?php echo $data->meta_title; ?>"/>
                                    </li>
                                    <li>
                                        <label for="meta_keywords" class="lable_title">metakeywords</label>
                                        <input name="meta_keywords" id="meta_keywords" class="text medium"  value="<?php echo $data->meta_keywords; ?>"/>
                                    </li>
                                    <li>
                                        <label for="meta_description" class="lable_title">metadescription</label>
                                        <textarea name="meta_description"  id="meta_description" class="textarea" style="width:500px;height:100px;"><?php echo $data->meta_description; ?></textarea>
                                    </li>
                                    </ul>
                                    <div style="clear:both;"></div>
                                </div>
                                <!--END tabs-1 -->

                                <!--Star tabs-2 -->
                                <div id="tabs-2">
                                    <ul>

                                        <li style="margin-bottom: 20px;">
                                            <label for="content" class="lable_title" >景区介绍</label>
                                            <textarea name="content"  id="content" class="textarea" style="width:700px;height:300px;"><?php echo $data->content; ?></textarea>
                                        </li>

                                        <li style="margin-bottom: 20px;">
                                            <label for="trafficinfo" class="lable_title" >交通信息 </label>
                                            <textarea name="trafficinfo"  id="trafficinfo" class="textarea" style="width:700px;height:300px;"><?php echo $data->trafficinfo; ?></textarea>
                                        </li>
                                        <li style="margin-bottom: 20px;">
                                            <label for="bookinfo" class="lable_title" >预订须知</label>
                                            <textarea name="bookinfo"  id="bookinfo" class="textarea" style="width:700px;height:300px;"><?php echo $data->bookinfo; ?></textarea>
                                        </li>

                                    </ul>
                                    <div style="clear:both;"></div>
                                </div>
                                <!--END tabs-2 -->
                                <!--Star tabs-3 -->
                                <div id="tabs-3">
                                    <ul>

                                        <li>
                                            <input id="custom_file_upload" type="file" name="Filedata" /> 
                                            <div id="custom-queue"></div>
                                            <div>
                                                <?php if (is_array($sightimages)): ?>
                                                    <?php foreach ($sightimages as $k => $v): ?>
                                                        <div id="removeimage<?php echo $v->id_image; ?>" class="photo_div">
                                                            <img src="<?php echo URL::base() . $v->url_image; ?>" width="160" height="160" class="photo"/>

                                                            <button class="delete" type="button"><?php echo $v->id_image ?></button>
                                                        </div>
                                                    <?php endforeach ?>
                                                <?php endif ?>
                                                <div style="clear:both"></div>
                                            </div>
                                        </li>

                                    </ul>
                                    <div style="clear:both;"></div>
                                </div>
                                <!--END tabs-3 -->
                            </div>
                            <ul>
                                <li style="text-align: center;">
                                    <input value="保存" class="button" type="submit"/>
                                </li>
                            </ul>
                            </form>
                            </div>
                            </div>
